# -*- coding: utf-8 -*-
from django.contrib import admin
from models import Area, User, Profile, Tweet, Friendship, PrivateMessage, Favorite, Reply


class AreaAdmin(admin.ModelAdmin):

    list_display = ('id', 'name', 'code')
    list_display_links = ('id', 'name', 'code')


class UserAdmin(admin.ModelAdmin):

    list_display = (
        'pk', 'id', 'username', 'password', 'email', 'first_name', 'last_name',
        'is_staff', 'is_active', 'is_superuser', 'last_login', 'date_joined')


class ProfileAdmin(admin.ModelAdmin):

    list_display = ('pk', 'id', 'user', 'nickname',
                    'area', 'avatar', 'homepage', 'about', 'addtime')
    list_display_links = ('user',)


class TweetAdmin(admin.ModelAdmin):

    list_display = ('id', 'user', 'message', 'addtime_format_admin', 'orginmessage')
    list_display_links = ('id',)
    search_fields = ['message']


class FriendshipAdmin(admin.ModelAdmin):

    list_display = ('id', 'fans', 'followers')


class PrivateMessageAdmin(admin.ModelAdmin):

    list_display = ('id', 'sender', 'privatemsg', 'receiver', 'isreader')

    class Media:
        js = (
            '/static/scripts/tinymce/tinymce.min.js',
            '/static/scripts/tinymce/config.js',
        )

class FavoriteAdmin(admin.ModelAdmin):

    list_display = ('id', 'favtweet', 'addtime')
    fields = ('favtweet','favuser')

class ReplyAdmin(admin.ModelAdmin):

    list_display = ('id', 'subject', 'replytweet', 'replyer', 'addtime')
    fields = ('subject', 'replytweet', 'replyer')

admin.site.register(Area, AreaAdmin)
admin.site.unregister(User)
admin.site.register(User, UserAdmin)
admin.site.register(Profile, ProfileAdmin)
admin.site.register(Tweet, TweetAdmin)
admin.site.register(Friendship, FriendshipAdmin)
admin.site.register(PrivateMessage, PrivateMessageAdmin)
admin.site.register(Favorite, FavoriteAdmin)
admin.site.register(Reply, ReplyAdmin)
